/**
 * @author n0tnull
 *
 */
package fr.gadcparis.envieparisienne;

import fr.gadcparis.envieparisienne.model.OpenDataClient;
import greendroid.app.GDActivity;
import greendroid.widget.ActionBar;
import greendroid.widget.ActionBarItem;
import greendroid.widget.ActionBarItem.Type;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class EnvieParisienneActivity extends GDActivity {
	
	private Context context;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar aBar = getActionBar();
        aBar.setTitle(this.getString(R.string.app_name));
        context = this;
        setActionBarContentView(R.layout.main);
        addActionBarItem(Type.Search, R.id.action_bar_search);
        addActionBarItem(Type.Info, R.id.action_bar_view_info);
    }
    
    @Override
    public boolean onHandleActionBarItemClick(ActionBarItem item, int position) {
    	switch (item.getItemId()) {
		case R.id.action_bar_view_info:
			startActivity(new Intent(context, AboutActivity.class));
			return true;
		case R.id.action_bar_search:
			startActivity(new Intent(context, SearchActivity.class));
			return true;
		default:
	    	return super.onHandleActionBarItemClick(item, position);
		}
    }
    
    public void onBtnClick(View v){
    	Bundle b = new Bundle();
    	Intent i;
    	
    	switch(v.getId()){
    	case R.id.main_around_btn:
			startActivity(new Intent(context, AroundMeActivity.class));
    		break;
    	case R.id.main_btn_hunger:
    		i = new Intent(context, SearchRestaurantActivity.class);
    		//b.putInt(context.getString(R.string.category_needed), OpenDataClient.HUNGER_CLIENT );
    		//i.putExtras(b);
			startActivity(i);
    		break;
    	case R.id.main_btn_thirsty:
    		i = new Intent(context, AroundMeActivity.class);
    		b.putInt(context.getString(R.string.category_needed), OpenDataClient.THIRSTY_CLIENT );
    		i.putExtras(b);
			startActivity(i);
			break;
    	case R.id.main_btn_pee:
    		i = new Intent(context, AroundMeActivity.class);
    		b.putInt(context.getString(R.string.category_needed), OpenDataClient.PEE_CLIENT );
    		i.putExtras(b);
			startActivity(i);
    		break;
    	case R.id.main_btn_sex:
		i = new Intent(context, AroundMeActivity.class);
    		b.putInt(context.getString(R.string.category_needed), OpenDataClient.SEX_CLIENT );
    		i.putExtras(b);
			startActivity(i);
    		break;
//    	case R.id.main_category_btn:
//			startActivity(new Intent(context, CategoryActivity.class));
//    		break;
    	default:
    		break;    	
    	}
    }
    
    
}